#!/usr/bin/env bash

MOUNTED=$(shopt -s nullglob dotglob; echo /mnt/share/*)

if (( ${#MOUNTED} )); then
    while (( ${#MOUNTED} )); do
        sudo umount -a -t cifs -l
        MOUNTED=$(shopt -s nullglob dotglob; echo /mnt/share/*)
    done
else
    echo "Remote directory not mounted"
fi
